const app = getApp()
Page({
  data: {
    navH: app.data.navHeight,
    wxData: {}
  },
  onLoad(option){
    var left = this;
    this.data.eventChannel = this.getOpenerEventChannel();
    this.data.eventChannel.on('TransferOfData', function (data) {
      left.data.url = data.url;
      left.data.typeurl = data.typeurl;
      left.data.executeType = data.executeType;
    })
  },
  onShow() {
    var nvabarData = {
      title: app.data.jsonPage.login.title,
      showCapsule: true
    }
    this.setData({
      nvabarData: nvabarData,
      btnText: app.data.jsonPage.login.btnText,
    })
  },
  wxlogin() {
    let that = this
    wx.login({
      success: res => {
        const code = res.code;
        let wxData = that.data.wxData;
        wxData.code = code;
        that.setData({
          wxData: wxData
        })
      },
    })
  },
  getUserInfo(e) {
    let that = this;
    wx.login({
      success: res => {
        const code = res.code;
        wx.getUserInfo({
          success: function (res) {
            let wxData = {};
            wxData.code = code;
            wxData.iv = res.iv;
            wxData.encryptedData = res.encryptedData;
            wxData.typeurl = that.data.typeurl;
            wxData.url = that.data.url;
            wxData.eventChannel = that.data.executeType?that.data.eventChannel:false;
            wx.$.login(wxData)
          }
        })
      },
    })
  }
})
